from rest_framework import serializers

from apps.aiauth.serializers import UsersSerializer
from apps.career.models import Careerplan, CareerplanExperts
from apps.setup.serializers import ExpertsSerializers, TimesLotSerializer


class CareerplanExpertsSerializer(serializers.ModelSerializer):
    experts_id = ExpertsSerializers()

    class Meta:
        model = CareerplanExperts
        fields = ('careerplan_id', 'experts_id')


class CareerSerializer(serializers.ModelSerializer):
    careerplanexperts = CareerplanExpertsSerializer(many=True)
    timeslot_id = TimesLotSerializer()
    user_id = UsersSerializer()
    create_time = serializers.DateTimeField('%Y-%m-%d %H:%M')
    publish_time = serializers.DateTimeField('%Y-%m-%d %H:%M')
    update_time = serializers.DateTimeField('%Y-%m-%d %H:%M')

    class Meta:
        model = Careerplan
        fields = (
            'careerplan_id', 'title', 'timeslot_id',
            'is_studymaster', 'create_time', 'publish_time',
            'update_time', 'status', 'user_id', 'careerplanexperts'
        )


class CareerDetailSerializer(serializers.ModelSerializer):
    careerplanexperts = CareerplanExpertsSerializer(many=True)
    timeslot_id = TimesLotSerializer()

    class Meta:
        model = Careerplan
        fields = (
            'careerplan_id', 'title', 'sub_message',
            'content_html', 'is_studymaster', 'timeslot_id',
            'careerplanexperts'
        )
